<?php
/**
 * Created by 项目.
 * User: xuguopeng
 * Date: 2020-01-07
 * Time: 16:03
 */

namespace app\api\controller\v1;


use app\api\model\WxMenu;
use app\api\model\WxMenus;
use LinCmsTp5\exception\ParameterException;
use think\facade\Request;
use app\api\service\Menu as MenuService;

class Menu
{
    /**
     * 获取菜单列表
     * @auth('微信菜单管理','微信菜单')
     */
    public function getMenuList()
    {
        return WxMenu::with('menus')->select()->toArray();
    }

    /**
     * 更新底部菜单
     *  @validate('IdMustBePositiveInt')
     */
    public function updateMenu($id,$name)
    {
        WxMenu::where('id','=',$id)->update(['name'=>$name]);
        return writeJson(202, [], '修改成功！');
    }

    /**
     * 更新底部子菜单
     *  @validate('IdMustBePositiveInt')
     */
    public function updateMenus()
    {
        $put = Request::put();
        $id = $put['id'];
        $name = $put['name'];
        $type = $put['type'];
        $open = $put['open'];
        $typevalue = $put['typevalue'];
        WxMenus::where('id','=',$id)->update([
            'name' => $name,
            'type' => $type,
            'open' => $open,
            'typevalue' => $typevalue,
        ]);
        return writeJson(202, [], '修改成功！');
    }

    /**
     * 创建自定义订单
     */
    public function createMenu()
    {
        $data = https_post("https://xiledaojia.com/api/v1/menus",[]);
        return json_decode($data,true);
    }
}